<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>Chapter 3. 头文件和链接</title>
    <link rel="stylesheet" href="style.css" type="text/css" />
    <meta name="generator" content="DocBook XSL Stylesheets V1.73.2" />
    <link rel="start" href="index.html" title="Clutter编程" />
    <link rel="up" href="index.html" title="Clutter编程" />
    <link rel="prev" href="sec-install_from_source.html" title="从源文件安装 Clutter" />
    <link rel="next" href="sec-stage.html" title="Chapter 4. Stage" />
  </head>
  <body>
    <div class="navheader">
      <table width="100%" summary="Navigation header">
        <tr>
          <th colspan="3" align="center">Chapter 3. 头文件和链接</th>
        </tr>
        <tr>
          <td width="20%" align="left"><a accesskey="p" href="sec-install_from_source.html"><img src="../icons/prev.png" alt="Prev" /></a> </td>
          <th width="60%" align="center"> </th>
          <td width="20%" align="right"> <a accesskey="n" href="sec-stage.html"><img src="../icons/next.png" alt="Next" /></a></td>
        </tr>
      </table>
      <hr />
    </div>
    <div class="chapter" lang="en" xml:lang="en">
      <div class="titlepage">
        <div>
          <div>
            <h2 class="title"><a id="chapter-headers-and-linking"></a>Chapter 3. 头文件和链接</h2>
          </div>
        </div>
      </div>
      <p>
使用 <span class="application">Clutter</span> APIs 必须包含头文件并与共享库链接，必需的编译和链接选项可以通过 pkg-config 工具获得：
</p>
      <p>
</p>
      <pre class="programlisting">
pkg-config clutter-0.8 --cflags
pkg-config clutter-0.8 --libs
</pre>
      <p>
</p>
      <p>
若使用 "autotools" (<span class="command"><strong>automake</strong></span>, <span class="command"><strong>autoconf</strong></span>,等) ， 可以在 configure.ac 中使用 <code class="function">PKG_CHECK_MODULES</code> 宏。例如:
</p>
      <p>
</p>
      <pre class="programlisting">
PKG_CHECK_MODULES(EXAMPLE, clutter-0.8)
AC_SUBST(EXAMPLE_CFLAGS)
AC_SUBST(EXAMPLE_LIBS)
</pre>
      <p>
</p>
      <p>
然后在 Makefile.am 中使用生成的 _CFLAGS 和 _LIBS 定义。注意，在 <code class="function">PKG_CHECK_MODULES</code> 调用中可能会碰到用空格分隔的其它库。比如，书中的一些例子用到类似 <code class="literal">clutter-gtk-0.8</code>，<code class="literal">clutter-cairo-0.8</code> 和 <code class="literal">clutter-gst-0.8</code>扩展库。</p>
    </div>
    <div class="navfooter">
      <hr />
      <table width="100%" summary="Navigation footer">
        <tr>
          <td width="40%" align="left"><a accesskey="p" href="sec-install_from_source.html"><img src="../icons/prev.png" alt="Prev" /></a> </td>
          <td width="20%" align="center"> </td>
          <td width="40%" align="right"> <a accesskey="n" href="sec-stage.html"><img src="../icons/next.png" alt="Next" /></a></td>
        </tr>
        <tr>
          <td width="40%" align="left" valign="top">从源文件安装 <span class="application">Clutter</span>  </td>
          <td width="20%" align="center">
            <a accesskey="h" href="index.html">
              <img src="../icons/home.png" alt="Home" />
            </a>
          </td>
          <td width="40%" align="right" valign="top"> Chapter 4. Stage</td>
        </tr>
      </table>
    </div>
  </body>
</html>
